﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Data;

namespace Chenxin.Lib.Business.DAL
{
    /// <summary>
    /// 数据访问类ContractInfo。
    /// </summary>
    public class ContractInfo
    {
        public ContractInfo()
        { }
        #region  成员方法

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static void Add(Chenxin.Lib.Business.Entity.ContractInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into tb_ContractInfo(");
            strSql.Append("Contract_Id,CityId,CityName,CompanyId,CompanyName,Contract_LastPrintUserId,Contract_LastPrintUserName,Contract_LastPrintDate,Contract_PrintCount,Contract_Type,Contract_Code,Contract_A,Contract_B,Contract_Content,Contract_PropertyCode,Contract_OwnerCode,Contract_LandUseCode,Contract_OtherCode,Contract_HouseArea,Contract_GargeArea,Contract_AtticCount,Contract_AtticArea,Contract_A_Identity,Contract_Mortgage,Contract_Use,Contract_OtherUse,Contract_RentStartDate,Contract_RentEndDate,Contract_ProvideDate,Contract_FreeDay,Contract_FreeStartDate,Contract_FreeEndDate,Contract_RenealDay,Contract_ReturnDay,Contract_LatePrice,Contract_EarnestDate,Contract_EarnestMoney,Contract_EarnestDay,Contract_EarnestUse,Contract_RentpriceDay,Contract_RentPriceMonth,Contract_RentPriceMonthUpper,Contract_RentPriceTax,Contract_PayMethod,Contract_PayUserName,Contract_PayUserCode,Contract_PayBank,Contract_A_Sure,Contract_RentKeep,Contract_RentKeepUnit,Contract_RentChange,Contract_RentChangeUnit,Contract_RentChangeContent,Contract_RentPayCycle,Contract_RentFirstDate,Contract_RentOtherTime,Contract_LateFree,Contract_LateOutDay,Contract_MarginCount,Contract_Margin,Contract_MarginUpper,Contract_MarginContainerEarnest,Contract_A_FreePay,Contract_B_FreePay,Contract_OtherFreePay,Contract_MaintainDay,Contract_ApprovalUser,Contract_CanSublet,Contract_Liqui_Both,Contract_A_LateDay,Contract_B_LateDay,Contract_Liqui_Other,Contract_Liqui_A,Contract_ChangeDealType,Contract_ChangeDeal,Contract_Liqui_B,Contract_Liqui,Contract_Remark,Contract_Count,Contract_OwnerPersonalOther,Contract_A_Name,Contract_A_Address,Contract_A_IdNumber,Contract_A_Agent,Contract_A_SureDate,Contract_B_Name,Contract_B_Address,Contract_B_IdNumber,Contract_B_Agent,Contract_B_SureDate,Contract_Date,Contract_Status)");
            strSql.Append(" values (");
            strSql.Append("@Contract_Id,@CityId,@CityName,@CompanyId,@CompanyName,@Contract_LastPrintUserId,@Contract_LastPrintUserName,@Contract_LastPrintDate,@Contract_PrintCount,@Contract_Type,@Contract_Code,@Contract_A,@Contract_B,@Contract_Content,@Contract_PropertyCode,@Contract_OwnerCode,@Contract_LandUseCode,@Contract_OtherCode,@Contract_HouseArea,@Contract_GargeArea,@Contract_AtticCount,@Contract_AtticArea,@Contract_A_Identity,@Contract_Mortgage,@Contract_Use,@Contract_OtherUse,@Contract_RentStartDate,@Contract_RentEndDate,@Contract_ProvideDate,@Contract_FreeDay,@Contract_FreeStartDate,@Contract_FreeEndDate,@Contract_RenealDay,@Contract_ReturnDay,@Contract_LatePrice,@Contract_EarnestDate,@Contract_EarnestMoney,@Contract_EarnestDay,@Contract_EarnestUse,@Contract_RentpriceDay,@Contract_RentPriceMonth,@Contract_RentPriceMonthUpper,@Contract_RentPriceTax,@Contract_PayMethod,@Contract_PayUserName,@Contract_PayUserCode,@Contract_PayBank,@Contract_A_Sure,@Contract_RentKeep,@Contract_RentKeepUnit,@Contract_RentChange,@Contract_RentChangeUnit,@Contract_RentChangeContent,@Contract_RentPayCycle,@Contract_RentFirstDate,@Contract_RentOtherTime,@Contract_LateFree,@Contract_LateOutDay,@Contract_MarginCount,@Contract_Margin,@Contract_MarginUpper,@Contract_MarginContainerEarnest,@Contract_A_FreePay,@Contract_B_FreePay,@Contract_OtherFreePay,@Contract_MaintainDay,@Contract_ApprovalUser,@Contract_CanSublet,@Contract_Liqui_Both,@Contract_A_LateDay,@Contract_B_LateDay,@Contract_Liqui_Other,@Contract_Liqui_A,@Contract_ChangeDealType,@Contract_ChangeDeal,@Contract_Liqui_B,@Contract_Liqui,@Contract_Remark,@Contract_Count,@Contract_OwnerPersonalOther,@Contract_A_Name,@Contract_A_Address,@Contract_A_IdNumber,@Contract_A_Agent,@Contract_A_SureDate,@Contract_B_Name,@Contract_B_Address,@Contract_B_IdNumber,@Contract_B_Agent,@Contract_B_SureDate,@Contract_Date,@Contract_Status)");
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            #region 参数
            db.AddInParameter(dbCommand, "@Contract_Id", DbType.Guid, model.Contract_Id);
            db.AddInParameter(dbCommand, "@CityId", DbType.Guid, model.CityId);
            db.AddInParameter(dbCommand, "@CityName", DbType.AnsiString, model.CityName);
            db.AddInParameter(dbCommand, "@CompanyId", DbType.Guid, model.CompanyId);
            db.AddInParameter(dbCommand, "@CompanyName", DbType.AnsiString, model.CompanyName);
            db.AddInParameter(dbCommand, "@Contract_LastPrintUserId", DbType.Guid, model.Contract_LastPrintUserId);
            db.AddInParameter(dbCommand, "@Contract_LastPrintUserName", DbType.AnsiString, model.Contract_LastPrintUserName);
            db.AddInParameter(dbCommand, "@Contract_LastPrintDate", DbType.DateTime, model.Contract_LastPrintDate);
            db.AddInParameter(dbCommand, "@Contract_PrintCount", DbType.Int32, model.Contract_PrintCount);
            db.AddInParameter(dbCommand, "@Contract_Type", DbType.Int32, model.Contract_Type);
            db.AddInParameter(dbCommand, "@Contract_Code", DbType.AnsiString, model.Contract_Code);
            db.AddInParameter(dbCommand, "@Contract_A", DbType.AnsiString, model.Contract_A);
            db.AddInParameter(dbCommand, "@Contract_B", DbType.AnsiString, model.Contract_B);
            db.AddInParameter(dbCommand, "@Contract_Content", DbType.AnsiString, model.Contract_Content);
            db.AddInParameter(dbCommand, "@Contract_PropertyCode", DbType.AnsiString, model.Contract_PropertyCode);
            db.AddInParameter(dbCommand, "@Contract_OwnerCode", DbType.AnsiString, model.Contract_OwnerCode);
            db.AddInParameter(dbCommand, "@Contract_LandUseCode", DbType.AnsiString, model.Contract_LandUseCode);
            db.AddInParameter(dbCommand, "@Contract_OtherCode", DbType.AnsiString, model.Contract_OtherCode);
            db.AddInParameter(dbCommand, "@Contract_HouseArea", DbType.Decimal, model.Contract_HouseArea);
            db.AddInParameter(dbCommand, "@Contract_GargeArea", DbType.Decimal, model.Contract_GargeArea);
            db.AddInParameter(dbCommand, "@Contract_AtticCount", DbType.Int32, model.Contract_AtticCount);
            db.AddInParameter(dbCommand, "@Contract_AtticArea", DbType.Decimal, model.Contract_AtticArea);
            db.AddInParameter(dbCommand, "@Contract_A_Identity", DbType.AnsiString, model.Contract_A_Identity);
            db.AddInParameter(dbCommand, "@Contract_Mortgage", DbType.AnsiString, model.Contract_Mortgage);
            db.AddInParameter(dbCommand, "@Contract_Use", DbType.AnsiString, model.Contract_Use);
            db.AddInParameter(dbCommand, "@Contract_OtherUse", DbType.AnsiString, model.Contract_OtherUse);
            db.AddInParameter(dbCommand, "@Contract_RentStartDate", DbType.DateTime, model.Contract_RentStartDate);
            db.AddInParameter(dbCommand, "@Contract_RentEndDate", DbType.DateTime, model.Contract_RentEndDate);
            db.AddInParameter(dbCommand, "@Contract_ProvideDate", DbType.DateTime, model.Contract_ProvideDate);
            db.AddInParameter(dbCommand, "@Contract_FreeDay", DbType.Int32, model.Contract_FreeDay);
            db.AddInParameter(dbCommand, "@Contract_FreeStartDate", DbType.DateTime, model.Contract_FreeStartDate);
            db.AddInParameter(dbCommand, "@Contract_FreeEndDate", DbType.DateTime, model.Contract_FreeEndDate);
            db.AddInParameter(dbCommand, "@Contract_RenealDay", DbType.Int32, model.Contract_RenealDay);
            db.AddInParameter(dbCommand, "@Contract_ReturnDay", DbType.Int32, model.Contract_ReturnDay);
            db.AddInParameter(dbCommand, "@Contract_LatePrice", DbType.Decimal, model.Contract_LatePrice);
            db.AddInParameter(dbCommand, "@Contract_EarnestDate", DbType.DateTime, model.Contract_EarnestDate);
            db.AddInParameter(dbCommand, "@Contract_EarnestMoney", DbType.Decimal, model.Contract_EarnestMoney);
            db.AddInParameter(dbCommand, "@Contract_EarnestDay", DbType.Int32, model.Contract_EarnestDay);
            db.AddInParameter(dbCommand, "@Contract_EarnestUse", DbType.AnsiString, model.Contract_EarnestUse);
            db.AddInParameter(dbCommand, "@Contract_RentpriceDay", DbType.Decimal, model.Contract_RentpriceDay);
            db.AddInParameter(dbCommand, "@Contract_RentPriceMonth", DbType.Decimal, model.Contract_RentPriceMonth);
            db.AddInParameter(dbCommand, "@Contract_RentPriceMonthUpper", DbType.AnsiString, model.Contract_RentPriceMonthUpper);
            db.AddInParameter(dbCommand, "@Contract_RentPriceTax", DbType.Boolean, model.Contract_RentPriceTax);
            db.AddInParameter(dbCommand, "@Contract_PayMethod", DbType.AnsiString, model.Contract_PayMethod);
            db.AddInParameter(dbCommand, "@Contract_PayUserName", DbType.AnsiString, model.Contract_PayUserName);
            db.AddInParameter(dbCommand, "@Contract_PayUserCode", DbType.AnsiString, model.Contract_PayUserCode);
            db.AddInParameter(dbCommand, "@Contract_PayBank", DbType.AnsiString, model.Contract_PayBank);
            db.AddInParameter(dbCommand, "@Contract_A_Sure", DbType.AnsiString, model.Contract_A_Sure);
            db.AddInParameter(dbCommand, "@Contract_RentKeep", DbType.Int32, model.Contract_RentKeep);
            db.AddInParameter(dbCommand, "@Contract_RentKeepUnit", DbType.AnsiString, model.Contract_RentKeepUnit);
            db.AddInParameter(dbCommand, "@Contract_RentChange", DbType.Int32, model.Contract_RentChange);
            db.AddInParameter(dbCommand, "@Contract_RentChangeUnit", DbType.AnsiString, model.Contract_RentChangeUnit);
            db.AddInParameter(dbCommand, "@Contract_RentChangeContent", DbType.AnsiString, model.Contract_RentChangeContent);
            db.AddInParameter(dbCommand, "@Contract_RentPayCycle", DbType.Int32, model.Contract_RentPayCycle);
            db.AddInParameter(dbCommand, "@Contract_RentFirstDate", DbType.DateTime, model.Contract_RentFirstDate);
            db.AddInParameter(dbCommand, "@Contract_RentOtherTime", DbType.AnsiString, model.Contract_RentOtherTime);
            db.AddInParameter(dbCommand, "@Contract_LateFree", DbType.Int32, model.Contract_LateFree);
            db.AddInParameter(dbCommand, "@Contract_LateOutDay", DbType.Int32, model.Contract_LateOutDay);
            db.AddInParameter(dbCommand, "@Contract_MarginCount", DbType.Int32, model.Contract_MarginCount);
            db.AddInParameter(dbCommand, "@Contract_Margin", DbType.Decimal, model.Contract_Margin);
            db.AddInParameter(dbCommand, "@Contract_MarginUpper", DbType.AnsiString, model.Contract_MarginUpper);
            db.AddInParameter(dbCommand, "@Contract_MarginContainerEarnest", DbType.Boolean, model.Contract_MarginContainerEarnest);
            db.AddInParameter(dbCommand, "@Contract_A_FreePay", DbType.AnsiString, model.Contract_A_FreePay);
            db.AddInParameter(dbCommand, "@Contract_B_FreePay", DbType.AnsiString, model.Contract_B_FreePay);
            db.AddInParameter(dbCommand, "@Contract_OtherFreePay", DbType.AnsiString, model.Contract_OtherFreePay);
            db.AddInParameter(dbCommand, "@Contract_MaintainDay", DbType.Int32, model.Contract_MaintainDay);
            db.AddInParameter(dbCommand, "@Contract_ApprovalUser", DbType.AnsiString, model.Contract_ApprovalUser);
            db.AddInParameter(dbCommand, "@Contract_CanSublet", DbType.Boolean, model.Contract_CanSublet);
            db.AddInParameter(dbCommand, "@Contract_Liqui_Both", DbType.Int32, model.Contract_Liqui_Both);
            db.AddInParameter(dbCommand, "@Contract_A_LateDay", DbType.Int32, model.Contract_A_LateDay);
            db.AddInParameter(dbCommand, "@Contract_B_LateDay", DbType.Int32, model.Contract_B_LateDay);
            db.AddInParameter(dbCommand, "@Contract_Liqui_Other", DbType.AnsiString, model.Contract_Liqui_Other);
            db.AddInParameter(dbCommand, "@Contract_Liqui_A", DbType.Int32, model.Contract_Liqui_A);
            db.AddInParameter(dbCommand, "@Contract_ChangeDealType", DbType.AnsiString, model.Contract_ChangeDealType);
            db.AddInParameter(dbCommand, "@Contract_ChangeDeal", DbType.AnsiString, model.Contract_ChangeDeal);
            db.AddInParameter(dbCommand, "@Contract_Liqui_B", DbType.Int32, model.Contract_Liqui_B);
            db.AddInParameter(dbCommand, "@Contract_Liqui", DbType.Int32, model.Contract_Liqui);
            db.AddInParameter(dbCommand, "@Contract_Remark", DbType.AnsiString, model.Contract_Remark);
            db.AddInParameter(dbCommand, "@Contract_Count", DbType.Int32, model.Contract_Count);
            db.AddInParameter(dbCommand, "@Contract_OwnerPersonalOther", DbType.AnsiString, model.Contract_OwnerPersonalOther);
            db.AddInParameter(dbCommand, "@Contract_A_Name", DbType.AnsiString, model.Contract_A_Name);
            db.AddInParameter(dbCommand, "@Contract_A_Address", DbType.AnsiString, model.Contract_A_Address);
            db.AddInParameter(dbCommand, "@Contract_A_IdNumber", DbType.AnsiString, model.Contract_A_IdNumber);
            db.AddInParameter(dbCommand, "@Contract_A_Agent", DbType.AnsiString, model.Contract_A_Agent);
            db.AddInParameter(dbCommand, "@Contract_A_SureDate", DbType.DateTime, model.Contract_A_SureDate);
            db.AddInParameter(dbCommand, "@Contract_B_Name", DbType.AnsiString, model.Contract_B_Name);
            db.AddInParameter(dbCommand, "@Contract_B_Address", DbType.AnsiString, model.Contract_B_Address);
            db.AddInParameter(dbCommand, "@Contract_B_IdNumber", DbType.AnsiString, model.Contract_B_IdNumber);
            db.AddInParameter(dbCommand, "@Contract_B_Agent", DbType.AnsiString, model.Contract_B_Agent);
            db.AddInParameter(dbCommand, "@Contract_B_SureDate", DbType.DateTime, model.Contract_B_SureDate);
            db.AddInParameter(dbCommand, "@Contract_Date", DbType.DateTime, model.Contract_Date);
            db.AddInParameter(dbCommand, "@Contract_Status", DbType.Int32, model.Contract_Status);
            #endregion

            db.ExecuteNonQuery(dbCommand);
        }

        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="modelId">记录的ModelId</param>
        /// <param name="status">状态，0为作废，10为正常</param>
        public static void ChangeStatus(Guid modelId, int status)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update tb_ContractInfo set ");
            strSql.Append("Contract_Status=@Contract_Status");
            strSql.Append(" where Contract_Id=@Contract_Id ");

            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            #region 参数
            db.AddInParameter(dbCommand, "@Contract_Id", DbType.Guid, modelId);
            db.AddInParameter(dbCommand, "@Contract_Status", DbType.Int32, status);
            #endregion

            db.ExecuteNonQuery(dbCommand);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static void Update(Chenxin.Lib.Business.Entity.ContractInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update tb_ContractInfo set ");
            strSql.Append("CityId=@CityId,");
            strSql.Append("CityName=@CityName,");
            strSql.Append("CompanyId=@CompanyId,");
            strSql.Append("CompanyName=@CompanyName,");
            strSql.Append("Contract_LastPrintUserId=@Contract_LastPrintUserId,");
            strSql.Append("Contract_LastPrintUserName=@Contract_LastPrintUserName,");
            strSql.Append("Contract_PrintCount=@Contract_PrintCount,");
            strSql.Append("Contract_Type=@Contract_Type,");
            strSql.Append("Contract_Code=@Contract_Code,");
            strSql.Append("Contract_A=@Contract_A,");
            strSql.Append("Contract_B=@Contract_B,");
            strSql.Append("Contract_Content=@Contract_Content,");
            strSql.Append("Contract_PropertyCode=@Contract_PropertyCode,");
            strSql.Append("Contract_OwnerCode=@Contract_OwnerCode,");
            strSql.Append("Contract_LandUseCode=@Contract_LandUseCode,");
            strSql.Append("Contract_OtherCode=@Contract_OtherCode,");
            strSql.Append("Contract_HouseArea=@Contract_HouseArea,");
            strSql.Append("Contract_GargeArea=@Contract_GargeArea,");
            strSql.Append("Contract_AtticCount=@Contract_AtticCount,");
            strSql.Append("Contract_AtticArea=@Contract_AtticArea,");
            strSql.Append("Contract_A_Identity=@Contract_A_Identity,");
            strSql.Append("Contract_Mortgage=@Contract_Mortgage,");
            strSql.Append("Contract_Use=@Contract_Use,");
            strSql.Append("Contract_OtherUse=@Contract_OtherUse,");
            strSql.Append("Contract_RentStartDate=@Contract_RentStartDate,");
            strSql.Append("Contract_RentEndDate=@Contract_RentEndDate,");
            strSql.Append("Contract_ProvideDate=@Contract_ProvideDate,");
            strSql.Append("Contract_FreeDay=@Contract_FreeDay,");
            strSql.Append("Contract_FreeStartDate=@Contract_FreeStartDate,");
            strSql.Append("Contract_FreeEndDate=@Contract_FreeEndDate,");
            strSql.Append("Contract_RenealDay=@Contract_RenealDay,");
            strSql.Append("Contract_ReturnDay=@Contract_ReturnDay,");
            strSql.Append("Contract_LatePrice=@Contract_LatePrice,");
            strSql.Append("Contract_EarnestDate=@Contract_EarnestDate,");
            strSql.Append("Contract_EarnestMoney=@Contract_EarnestMoney,");
            strSql.Append("Contract_EarnestDay=@Contract_EarnestDay,");
            strSql.Append("Contract_EarnestUse=@Contract_EarnestUse,");
            strSql.Append("Contract_RentpriceDay=@Contract_RentpriceDay,");
            strSql.Append("Contract_RentPriceMonth=@Contract_RentPriceMonth,");
            strSql.Append("Contract_RentPriceMonthUpper=@Contract_RentPriceMonthUpper,");
            strSql.Append("Contract_RentPriceTax=@Contract_RentPriceTax,");
            strSql.Append("Contract_PayMethod=@Contract_PayMethod,");
            strSql.Append("Contract_PayUserName=@Contract_PayUserName,");
            strSql.Append("Contract_PayUserCode=@Contract_PayUserCode,");
            strSql.Append("Contract_PayBank=@Contract_PayBank,");
            strSql.Append("Contract_A_Sure=@Contract_A_Sure,");
            strSql.Append("Contract_RentKeep=@Contract_RentKeep,");
            strSql.Append("Contract_RentKeepUnit=@Contract_RentKeepUnit,");
            strSql.Append("Contract_RentChange=@Contract_RentChange,");
            strSql.Append("Contract_RentChangeUnit=@Contract_RentChangeUnit,");
            strSql.Append("Contract_RentChangeContent=@Contract_RentChangeContent,");
            strSql.Append("Contract_RentPayCycle=@Contract_RentPayCycle,");
            strSql.Append("Contract_RentFirstDate=@Contract_RentFirstDate,");
            strSql.Append("Contract_RentOtherTime=@Contract_RentOtherTime,");
            strSql.Append("Contract_LateFree=@Contract_LateFree,");
            strSql.Append("Contract_LateOutDay=@Contract_LateOutDay,");
            strSql.Append("Contract_MarginCount=@Contract_MarginCount,");
            strSql.Append("Contract_Margin=@Contract_Margin,");
            strSql.Append("Contract_MarginUpper=@Contract_MarginUpper,");
            strSql.Append("Contract_MarginContainerEarnest=@Contract_MarginContainerEarnest,");
            strSql.Append("Contract_A_FreePay=@Contract_A_FreePay,");
            strSql.Append("Contract_B_FreePay=@Contract_B_FreePay,");
            strSql.Append("Contract_OtherFreePay=@Contract_OtherFreePay,");
            strSql.Append("Contract_MaintainDay=@Contract_MaintainDay,");
            strSql.Append("Contract_ApprovalUser=@Contract_ApprovalUser,");
            strSql.Append("Contract_CanSublet=@Contract_CanSublet,");
            strSql.Append("Contract_Liqui_Both=@Contract_Liqui_Both,");
            strSql.Append("Contract_A_LateDay=@Contract_A_LateDay,");
            strSql.Append("Contract_B_LateDay=@Contract_B_LateDay,");
            strSql.Append("Contract_Liqui_Other=@Contract_Liqui_Other,");
            strSql.Append("Contract_Liqui_A=@Contract_Liqui_A,");
            strSql.Append("Contract_ChangeDealType=@Contract_ChangeDealType,");
            strSql.Append("Contract_ChangeDeal=@Contract_ChangeDeal,");
            strSql.Append("Contract_Liqui_B=@Contract_Liqui_B,");
            strSql.Append("Contract_Liqui=@Contract_Liqui,");
            strSql.Append("Contract_Remark=@Contract_Remark,");
            strSql.Append("Contract_Count=@Contract_Count,");
            strSql.Append("Contract_OwnerPersonalOther=@Contract_OwnerPersonalOther,");
            strSql.Append("Contract_A_Name=@Contract_A_Name,");
            strSql.Append("Contract_A_Address=@Contract_A_Address,");
            strSql.Append("Contract_A_IdNumber=@Contract_A_IdNumber,");
            strSql.Append("Contract_A_Agent=@Contract_A_Agent,");
            strSql.Append("Contract_A_SureDate=@Contract_A_SureDate,");
            strSql.Append("Contract_B_Name=@Contract_B_Name,");
            strSql.Append("Contract_B_Address=@Contract_B_Address,");
            strSql.Append("Contract_B_IdNumber=@Contract_B_IdNumber,");
            strSql.Append("Contract_B_Agent=@Contract_B_Agent,");
            strSql.Append("Contract_B_SureDate=@Contract_B_SureDate,");
            strSql.Append("Contract_Date=@Contract_Date,");
            strSql.Append("Contract_Status=@Contract_Status");
            strSql.Append(" where Contract_Id=@Contract_Id ");

            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            #region 参数
            db.AddInParameter(dbCommand, "@Contract_Id", DbType.Guid, model.Contract_Id);
            db.AddInParameter(dbCommand, "@CityId", DbType.Guid, model.CityId);
            db.AddInParameter(dbCommand, "@CityName", DbType.AnsiString, model.CityName);
            db.AddInParameter(dbCommand, "@CompanyId", DbType.Guid, model.CompanyId);
            db.AddInParameter(dbCommand, "@CompanyName", DbType.AnsiString, model.CompanyName);
            db.AddInParameter(dbCommand, "@Contract_LastPrintUserId", DbType.Guid, model.Contract_LastPrintUserId);
            db.AddInParameter(dbCommand, "@Contract_LastPrintUserName", DbType.AnsiString, model.Contract_LastPrintUserName);
            db.AddInParameter(dbCommand, "@Contract_LastPrintDate", DbType.DateTime, model.Contract_LastPrintDate);
            db.AddInParameter(dbCommand, "@Contract_PrintCount", DbType.Int32, model.Contract_PrintCount);
            db.AddInParameter(dbCommand, "@Contract_Type", DbType.Int32, model.Contract_Type);
            db.AddInParameter(dbCommand, "@Contract_Code", DbType.AnsiString, model.Contract_Type);
            db.AddInParameter(dbCommand, "@Contract_A", DbType.AnsiString, model.Contract_A);
            db.AddInParameter(dbCommand, "@Contract_B", DbType.AnsiString, model.Contract_B);
            db.AddInParameter(dbCommand, "@Contract_Content", DbType.AnsiString, model.Contract_Content);
            db.AddInParameter(dbCommand, "@Contract_PropertyCode", DbType.AnsiString, model.Contract_PropertyCode);
            db.AddInParameter(dbCommand, "@Contract_OwnerCode", DbType.AnsiString, model.Contract_OwnerCode);
            db.AddInParameter(dbCommand, "@Contract_LandUseCode", DbType.AnsiString, model.Contract_LandUseCode);
            db.AddInParameter(dbCommand, "@Contract_OtherCode", DbType.AnsiString, model.Contract_OtherCode);
            db.AddInParameter(dbCommand, "@Contract_HouseArea", DbType.Decimal, model.Contract_HouseArea);
            db.AddInParameter(dbCommand, "@Contract_GargeArea", DbType.Decimal, model.Contract_GargeArea);
            db.AddInParameter(dbCommand, "@Contract_AtticCount", DbType.Int32, model.Contract_AtticCount);
            db.AddInParameter(dbCommand, "@Contract_AtticArea", DbType.Decimal, model.Contract_AtticArea);
            db.AddInParameter(dbCommand, "@Contract_A_Identity", DbType.AnsiString, model.Contract_A_Identity);
            db.AddInParameter(dbCommand, "@Contract_Mortgage", DbType.AnsiString, model.Contract_Mortgage);
            db.AddInParameter(dbCommand, "@Contract_Use", DbType.AnsiString, model.Contract_Use);
            db.AddInParameter(dbCommand, "@Contract_OtherUse", DbType.AnsiString, model.Contract_OtherUse);
            db.AddInParameter(dbCommand, "@Contract_RentStartDate", DbType.DateTime, model.Contract_RentStartDate);
            db.AddInParameter(dbCommand, "@Contract_RentEndDate", DbType.DateTime, model.Contract_RentEndDate);
            db.AddInParameter(dbCommand, "@Contract_ProvideDate", DbType.DateTime, model.Contract_ProvideDate);
            db.AddInParameter(dbCommand, "@Contract_FreeDay", DbType.Int32, model.Contract_FreeDay);
            db.AddInParameter(dbCommand, "@Contract_FreeStartDate", DbType.DateTime, model.Contract_FreeStartDate);
            db.AddInParameter(dbCommand, "@Contract_FreeEndDate", DbType.DateTime, model.Contract_FreeEndDate);
            db.AddInParameter(dbCommand, "@Contract_RenealDay", DbType.Int32, model.Contract_RenealDay);
            db.AddInParameter(dbCommand, "@Contract_ReturnDay", DbType.Int32, model.Contract_ReturnDay);
            db.AddInParameter(dbCommand, "@Contract_LatePrice", DbType.Decimal, model.Contract_LatePrice);
            db.AddInParameter(dbCommand, "@Contract_EarnestDate", DbType.DateTime, model.Contract_EarnestDate);
            db.AddInParameter(dbCommand, "@Contract_EarnestMoney", DbType.Decimal, model.Contract_EarnestMoney);
            db.AddInParameter(dbCommand, "@Contract_EarnestDay", DbType.Int32, model.Contract_EarnestDay);
            db.AddInParameter(dbCommand, "@Contract_EarnestUse", DbType.AnsiString, model.Contract_EarnestUse);
            db.AddInParameter(dbCommand, "@Contract_RentpriceDay", DbType.Decimal, model.Contract_RentpriceDay);
            db.AddInParameter(dbCommand, "@Contract_RentPriceMonth", DbType.Decimal, model.Contract_RentPriceMonth);
            db.AddInParameter(dbCommand, "@Contract_RentPriceMonthUpper", DbType.AnsiString, model.Contract_RentPriceMonthUpper);
            db.AddInParameter(dbCommand, "@Contract_RentPriceTax", DbType.Boolean, model.Contract_RentPriceTax);
            db.AddInParameter(dbCommand, "@Contract_PayMethod", DbType.AnsiString, model.Contract_PayMethod);
            db.AddInParameter(dbCommand, "@Contract_PayUserName", DbType.AnsiString, model.Contract_PayUserName);
            db.AddInParameter(dbCommand, "@Contract_PayUserCode", DbType.AnsiString, model.Contract_PayUserCode);
            db.AddInParameter(dbCommand, "@Contract_PayBank", DbType.AnsiString, model.Contract_PayBank);
            db.AddInParameter(dbCommand, "@Contract_A_Sure", DbType.AnsiString, model.Contract_A_Sure);
            db.AddInParameter(dbCommand, "@Contract_RentKeep", DbType.Int32, model.Contract_RentKeep);
            db.AddInParameter(dbCommand, "@Contract_RentKeepUnit", DbType.AnsiString, model.Contract_RentKeepUnit);
            db.AddInParameter(dbCommand, "@Contract_RentChange", DbType.Int32, model.Contract_RentChange);
            db.AddInParameter(dbCommand, "@Contract_RentChangeUnit", DbType.AnsiString, model.Contract_RentChangeUnit);
            db.AddInParameter(dbCommand, "@Contract_RentChangeContent", DbType.AnsiString, model.Contract_RentChangeContent);
            db.AddInParameter(dbCommand, "@Contract_RentPayCycle", DbType.Int32, model.Contract_RentPayCycle);
            db.AddInParameter(dbCommand, "@Contract_RentFirstDate", DbType.DateTime, model.Contract_RentFirstDate);
            db.AddInParameter(dbCommand, "@Contract_RentOtherTime", DbType.AnsiString, model.Contract_RentOtherTime);
            db.AddInParameter(dbCommand, "@Contract_LateFree", DbType.Int32, model.Contract_LateFree);
            db.AddInParameter(dbCommand, "@Contract_LateOutDay", DbType.Int32, model.Contract_LateOutDay);
            db.AddInParameter(dbCommand, "@Contract_MarginCount", DbType.Int32, model.Contract_MarginCount);
            db.AddInParameter(dbCommand, "@Contract_Margin", DbType.Decimal, model.Contract_Margin);
            db.AddInParameter(dbCommand, "@Contract_MarginUpper", DbType.AnsiString, model.Contract_MarginUpper);
            db.AddInParameter(dbCommand, "@Contract_MarginContainerEarnest", DbType.Boolean, model.Contract_MarginContainerEarnest);
            db.AddInParameter(dbCommand, "@Contract_A_FreePay", DbType.AnsiString, model.Contract_A_FreePay);
            db.AddInParameter(dbCommand, "@Contract_B_FreePay", DbType.AnsiString, model.Contract_B_FreePay);
            db.AddInParameter(dbCommand, "@Contract_OtherFreePay", DbType.AnsiString, model.Contract_OtherFreePay);
            db.AddInParameter(dbCommand, "@Contract_MaintainDay", DbType.Int32, model.Contract_MaintainDay);
            db.AddInParameter(dbCommand, "@Contract_ApprovalUser", DbType.AnsiString, model.Contract_ApprovalUser);
            db.AddInParameter(dbCommand, "@Contract_CanSublet", DbType.Boolean, model.Contract_CanSublet);
            db.AddInParameter(dbCommand, "@Contract_Liqui_Both", DbType.Int32, model.Contract_Liqui_Both);
            db.AddInParameter(dbCommand, "@Contract_A_LateDay", DbType.Int32, model.Contract_A_LateDay);
            db.AddInParameter(dbCommand, "@Contract_B_LateDay", DbType.Int32, model.Contract_B_LateDay);
            db.AddInParameter(dbCommand, "@Contract_Liqui_Other", DbType.AnsiString, model.Contract_Liqui_Other);
            db.AddInParameter(dbCommand, "@Contract_Liqui_A", DbType.Int32, model.Contract_Liqui_A);
            db.AddInParameter(dbCommand, "@Contract_ChangeDealType", DbType.AnsiString, model.Contract_ChangeDealType);
            db.AddInParameter(dbCommand, "@Contract_ChangeDeal", DbType.AnsiString, model.Contract_ChangeDeal);
            db.AddInParameter(dbCommand, "@Contract_Liqui_B", DbType.Int32, model.Contract_Liqui_B);
            db.AddInParameter(dbCommand, "@Contract_Liqui", DbType.Int32, model.Contract_Liqui);
            db.AddInParameter(dbCommand, "@Contract_Remark", DbType.AnsiString, model.Contract_Remark);
            db.AddInParameter(dbCommand, "@Contract_Count", DbType.Int32, model.Contract_Count);
            db.AddInParameter(dbCommand, "@Contract_OwnerPersonalOther", DbType.AnsiString, model.Contract_OwnerPersonalOther);
            db.AddInParameter(dbCommand, "@Contract_A_Name", DbType.AnsiString, model.Contract_A_Name);
            db.AddInParameter(dbCommand, "@Contract_A_Address", DbType.AnsiString, model.Contract_A_Address);
            db.AddInParameter(dbCommand, "@Contract_A_IdNumber", DbType.AnsiString, model.Contract_A_IdNumber);
            db.AddInParameter(dbCommand, "@Contract_A_Agent", DbType.AnsiString, model.Contract_A_Agent);
            db.AddInParameter(dbCommand, "@Contract_A_SureDate", DbType.DateTime, model.Contract_A_SureDate);
            db.AddInParameter(dbCommand, "@Contract_B_Name", DbType.AnsiString, model.Contract_B_Name);
            db.AddInParameter(dbCommand, "@Contract_B_Address", DbType.AnsiString, model.Contract_B_Address);
            db.AddInParameter(dbCommand, "@Contract_B_IdNumber", DbType.AnsiString, model.Contract_B_IdNumber);
            db.AddInParameter(dbCommand, "@Contract_B_Agent", DbType.AnsiString, model.Contract_B_Agent);
            db.AddInParameter(dbCommand, "@Contract_B_SureDate", DbType.DateTime, model.Contract_B_SureDate);
            db.AddInParameter(dbCommand, "@Contract_Date", DbType.DateTime, model.Contract_Date);
            db.AddInParameter(dbCommand, "@Contract_Status", DbType.Int32, model.Contract_Status);
            #endregion

            db.ExecuteNonQuery(dbCommand);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static void Delete(Guid Contract_Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from tb_ContractInfo ");
            strSql.Append(" where Contract_Id=@Contract_Id ");
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());


            db.AddInParameter(dbCommand, "@Contract_Id", DbType.Guid, Contract_Id);

            db.ExecuteNonQuery(dbCommand);
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Chenxin.Lib.Business.Entity.ContractInfo GetModel(Guid Contract_Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Contract_Id,CityId,CityName,CompanyId,CompanyName,Contract_LastPrintUserId,Contract_LastPrintUserName,Contract_LastPrintDate,Contract_PrintCount,Contract_Type,Contract_Code,Contract_A,Contract_B,Contract_Content,Contract_PropertyCode,Contract_OwnerCode,Contract_LandUseCode,Contract_OtherCode,Contract_HouseArea,Contract_GargeArea,Contract_AtticCount,Contract_AtticArea,Contract_A_Identity,Contract_Mortgage,Contract_Use,Contract_OtherUse,Contract_RentStartDate,Contract_RentEndDate,Contract_ProvideDate,Contract_FreeDay,Contract_FreeStartDate,Contract_FreeEndDate,Contract_RenealDay,Contract_ReturnDay,Contract_LatePrice,Contract_EarnestDate,Contract_EarnestMoney,Contract_EarnestDay,Contract_EarnestUse,Contract_RentpriceDay,Contract_RentPriceMonth,Contract_RentPriceMonthUpper,Contract_RentPriceTax,Contract_PayMethod,Contract_PayUserName,Contract_PayUserCode,Contract_PayBank,Contract_A_Sure,Contract_RentKeep,Contract_RentKeepUnit,Contract_RentChange,Contract_RentChangeUnit,Contract_RentChangeContent,Contract_RentPayCycle,Contract_RentFirstDate,Contract_RentOtherTime,Contract_LateFree,Contract_LateOutDay,Contract_MarginCount,Contract_Margin,Contract_MarginUpper,Contract_MarginContainerEarnest,Contract_A_FreePay,Contract_B_FreePay,Contract_OtherFreePay,Contract_MaintainDay,Contract_ApprovalUser,Contract_CanSublet,Contract_Liqui_Both,Contract_A_LateDay,Contract_B_LateDay,Contract_Liqui_Other,Contract_Liqui_A,Contract_ChangeDealType,Contract_ChangeDeal,Contract_Liqui_B,Contract_Liqui,Contract_Remark,Contract_Count,Contract_OwnerPersonalOther,Contract_A_Name,Contract_A_Address,Contract_A_IdNumber,Contract_A_Agent,Contract_A_SureDate,Contract_B_Name,Contract_B_Address,Contract_B_IdNumber,Contract_B_Agent,Contract_B_SureDate,Contract_Date,Contract_Status from tb_ContractInfo ");
            strSql.Append(" where Contract_Id=@Contract_Id ");

            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "Contract_Id", DbType.Guid, Contract_Id);
            Chenxin.Lib.Business.Entity.ContractInfo model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                dataReader.Close();
                dataReader.Dispose();
            }
            return model;
        }


        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public static Chenxin.Lib.Business.Entity.ContractInfo ReaderBind(IDataReader dataReader)
        {
            Chenxin.Lib.Business.Entity.ContractInfo model = new Chenxin.Lib.Business.Entity.ContractInfo();
            if (dataReader["Contract_Id"].ToString() != "")
            {
                model.Contract_Id = new Guid(dataReader["Contract_Id"].ToString());
            }
            if (dataReader["CityId"].ToString() != "")
            {
                model.CityId = new Guid(dataReader["CityId"].ToString());
            }
            model.CityName = dataReader["CityName"].ToString();
            if (dataReader["CompanyId"].ToString() != "")
            {
                model.CompanyId = new Guid(dataReader["CompanyId"].ToString());
            }
            model.CompanyName = dataReader["CompanyName"].ToString();
            if (dataReader["Contract_LastPrintUserId"].ToString() != "")
            {
                model.Contract_LastPrintUserId = new Guid(dataReader["Contract_LastPrintUserId"].ToString());
            }
            model.Contract_LastPrintUserName = dataReader["Contract_LastPrintUserName"].ToString();
            if (dataReader["Contract_LastPrintDate"].ToString() != "")
            {
                model.Contract_LastPrintDate = DateTime.Parse(dataReader["Contract_LastPrintDate"].ToString());
            }
            if (dataReader["Contract_PrintCount"].ToString() != "")
            {
                model.Contract_PrintCount = int.Parse(dataReader["Contract_PrintCount"].ToString());
            }
            if (dataReader["Contract_Type"].ToString() != "")
            {
                model.Contract_Type = int.Parse(dataReader["Contract_Type"].ToString());
            }
            model.Contract_Code = dataReader["Contract_Code"].ToString();
            model.Contract_A = dataReader["Contract_A"].ToString();
            model.Contract_B = dataReader["Contract_B"].ToString();
            model.Contract_Content = dataReader["Contract_Content"].ToString();
            model.Contract_PropertyCode = dataReader["Contract_PropertyCode"].ToString();
            model.Contract_OwnerCode = dataReader["Contract_OwnerCode"].ToString();
            model.Contract_LandUseCode = dataReader["Contract_LandUseCode"].ToString();
            model.Contract_OtherCode = dataReader["Contract_OtherCode"].ToString();
            if (dataReader["Contract_HouseArea"].ToString() != "")
            {
                model.Contract_HouseArea = decimal.Parse(dataReader["Contract_HouseArea"].ToString());
            }
            if (dataReader["Contract_GargeArea"].ToString() != "")
            {
                model.Contract_GargeArea = decimal.Parse(dataReader["Contract_GargeArea"].ToString());
            }
            if (dataReader["Contract_AtticCount"].ToString() != "")
            {
                model.Contract_AtticCount = int.Parse(dataReader["Contract_AtticCount"].ToString());
            }
            if (dataReader["Contract_AtticArea"].ToString() != "")
            {
                model.Contract_AtticArea = decimal.Parse(dataReader["Contract_AtticArea"].ToString());
            }
            model.Contract_A_Identity = dataReader["Contract_A_Identity"].ToString();
            model.Contract_Mortgage = dataReader["Contract_Mortgage"].ToString();
            model.Contract_Use = dataReader["Contract_Use"].ToString();
            model.Contract_OtherUse = dataReader["Contract_OtherUse"].ToString();
            if (dataReader["Contract_RentStartDate"].ToString() != "")
            {
                model.Contract_RentStartDate = DateTime.Parse(dataReader["Contract_RentStartDate"].ToString());
            }
            if (dataReader["Contract_RentEndDate"].ToString() != "")
            {
                model.Contract_RentEndDate = DateTime.Parse(dataReader["Contract_RentEndDate"].ToString());
            }
            if (dataReader["Contract_ProvideDate"].ToString() != "")
            {
                model.Contract_ProvideDate = DateTime.Parse(dataReader["Contract_ProvideDate"].ToString());
            }
            if (dataReader["Contract_FreeDay"].ToString() != "")
            {
                model.Contract_FreeDay = int.Parse(dataReader["Contract_FreeDay"].ToString());
            }
            if (dataReader["Contract_FreeStartDate"].ToString() != "")
            {
                model.Contract_FreeStartDate = DateTime.Parse(dataReader["Contract_FreeStartDate"].ToString());
            }
            if (dataReader["Contract_FreeEndDate"].ToString() != "")
            {
                model.Contract_FreeEndDate = DateTime.Parse(dataReader["Contract_FreeEndDate"].ToString());
            }
            if (dataReader["Contract_RenealDay"].ToString() != "")
            {
                model.Contract_RenealDay = int.Parse(dataReader["Contract_RenealDay"].ToString());
            }
            if (dataReader["Contract_ReturnDay"].ToString() != "")
            {
                model.Contract_ReturnDay = int.Parse(dataReader["Contract_ReturnDay"].ToString());
            }
            if (dataReader["Contract_LatePrice"].ToString() != "")
            {
                model.Contract_LatePrice = decimal.Parse(dataReader["Contract_LatePrice"].ToString());
            }
            if (dataReader["Contract_EarnestDate"].ToString() != "")
            {
                model.Contract_EarnestDate = DateTime.Parse(dataReader["Contract_EarnestDate"].ToString());
            }
            if (dataReader["Contract_EarnestMoney"].ToString() != "")
            {
                model.Contract_EarnestMoney = decimal.Parse(dataReader["Contract_EarnestMoney"].ToString());
            }
            if (dataReader["Contract_EarnestDay"].ToString() != "")
            {
                model.Contract_EarnestDay = int.Parse(dataReader["Contract_EarnestDay"].ToString());
            }
            model.Contract_EarnestUse = dataReader["Contract_EarnestUse"].ToString();
            if (dataReader["Contract_RentpriceDay"].ToString() != "")
            {
                model.Contract_RentpriceDay = decimal.Parse(dataReader["Contract_RentpriceDay"].ToString());
            }
            if (dataReader["Contract_RentPriceMonth"].ToString() != "")
            {
                model.Contract_RentPriceMonth = decimal.Parse(dataReader["Contract_RentPriceMonth"].ToString());
            }
            model.Contract_RentPriceMonthUpper = dataReader["Contract_RentPriceMonthUpper"].ToString();
            if (dataReader["Contract_RentPriceTax"].ToString() != "")
            {
                if ((dataReader["Contract_RentPriceTax"].ToString() == "1") || (dataReader["Contract_RentPriceTax"].ToString().ToLower() == "true"))
                {
                    model.Contract_RentPriceTax = true;
                }
                else
                {
                    model.Contract_RentPriceTax = false;
                }
            }
            model.Contract_PayMethod = dataReader["Contract_PayMethod"].ToString();
            model.Contract_PayUserName = dataReader["Contract_PayUserName"].ToString();
            model.Contract_PayUserCode = dataReader["Contract_PayUserCode"].ToString();
            model.Contract_PayBank = dataReader["Contract_PayBank"].ToString();
            model.Contract_A_Sure = dataReader["Contract_A_Sure"].ToString();
            if (dataReader["Contract_RentKeep"].ToString() != "")
            {
                model.Contract_RentKeep = int.Parse(dataReader["Contract_RentKeep"].ToString());
            }
            model.Contract_RentKeepUnit = dataReader["Contract_RentKeepUnit"].ToString();
            if (dataReader["Contract_RentChange"].ToString() != "")
            {
                model.Contract_RentChange = int.Parse(dataReader["Contract_RentChange"].ToString());
            }
            model.Contract_RentChangeUnit = dataReader["Contract_RentChangeUnit"].ToString();
            model.Contract_RentChangeContent = dataReader["Contract_RentChangeContent"].ToString();
            if (dataReader["Contract_RentPayCycle"].ToString() != "")
            {
                model.Contract_RentPayCycle = int.Parse(dataReader["Contract_RentPayCycle"].ToString());
            }
            if (dataReader["Contract_RentFirstDate"].ToString() != "")
            {
                model.Contract_RentFirstDate = DateTime.Parse(dataReader["Contract_RentFirstDate"].ToString());
            }
            model.Contract_RentOtherTime = dataReader["Contract_RentOtherTime"].ToString();
            if (dataReader["Contract_LateFree"].ToString() != "")
            {
                model.Contract_LateFree = int.Parse(dataReader["Contract_LateFree"].ToString());
            }
            if (dataReader["Contract_LateOutDay"].ToString() != "")
            {
                model.Contract_LateOutDay = int.Parse(dataReader["Contract_LateOutDay"].ToString());
            }
            if (dataReader["Contract_MarginCount"].ToString() != "")
            {
                model.Contract_MarginCount = int.Parse(dataReader["Contract_MarginCount"].ToString());
            }
            if (dataReader["Contract_Margin"].ToString() != "")
            {
                model.Contract_Margin = decimal.Parse(dataReader["Contract_Margin"].ToString());
            }
            model.Contract_MarginUpper = dataReader["Contract_MarginUpper"].ToString();

            if (dataReader["Contract_MarginContainerEarnest"].ToString() != "")
            {
                if ((dataReader["Contract_MarginContainerEarnest"].ToString() == "1") || (dataReader["Contract_MarginContainerEarnest"].ToString().ToLower() == "true"))
                {
                    model.Contract_MarginContainerEarnest = true;
                }
                else
                {
                    model.Contract_MarginContainerEarnest = false;
                }
            }
            model.Contract_A_FreePay = dataReader["Contract_A_FreePay"].ToString();
            model.Contract_B_FreePay = dataReader["Contract_B_FreePay"].ToString();
            model.Contract_OtherFreePay = dataReader["Contract_OtherFreePay"].ToString();
            if (dataReader["Contract_MaintainDay"].ToString() != "")
            {
                model.Contract_MaintainDay = int.Parse(dataReader["Contract_MaintainDay"].ToString());
            }
            model.Contract_ApprovalUser = dataReader["Contract_ApprovalUser"].ToString();
            if (dataReader["Contract_CanSublet"].ToString() != "")
            {
                if ((dataReader["Contract_CanSublet"].ToString() == "1") || (dataReader["Contract_CanSublet"].ToString().ToLower() == "true"))
                {
                    model.Contract_CanSublet = true;
                }
                else
                {
                    model.Contract_CanSublet = false;
                }
            }
            if (dataReader["Contract_Liqui_Both"].ToString() != "")
            {
                model.Contract_Liqui_Both = int.Parse(dataReader["Contract_Liqui_Both"].ToString());
            }
            if (dataReader["Contract_A_LateDay"].ToString() != "")
            {
                model.Contract_A_LateDay = int.Parse(dataReader["Contract_A_LateDay"].ToString());
            }
            if (dataReader["Contract_B_LateDay"].ToString() != "")
            {
                model.Contract_B_LateDay = int.Parse(dataReader["Contract_B_LateDay"].ToString());
            }
            model.Contract_Liqui_Other = dataReader["Contract_Liqui_Other"].ToString();
            if (dataReader["Contract_Liqui_A"].ToString() != "")
            {
                model.Contract_Liqui_A = int.Parse(dataReader["Contract_Liqui_A"].ToString());
            }
            model.Contract_ChangeDealType = dataReader["Contract_ChangeDealType"].ToString();
            model.Contract_ChangeDeal = dataReader["Contract_ChangeDeal"].ToString();
            if (dataReader["Contract_Liqui_B"].ToString() != "")
            {
                model.Contract_Liqui_B = int.Parse(dataReader["Contract_Liqui_B"].ToString());
            }
            if (dataReader["Contract_Liqui"].ToString() != "")
            {
                model.Contract_Liqui = int.Parse(dataReader["Contract_Liqui"].ToString());
            }
            model.Contract_Remark = dataReader["Contract_Remark"].ToString();
            if (dataReader["Contract_Count"].ToString() != "")
            {
                model.Contract_Count = int.Parse(dataReader["Contract_Count"].ToString());
            }
            model.Contract_OwnerPersonalOther = dataReader["Contract_OwnerPersonalOther"].ToString();
            model.Contract_A_Name = dataReader["Contract_A_Name"].ToString();
            model.Contract_A_Address = dataReader["Contract_A_Address"].ToString();
            model.Contract_A_IdNumber = dataReader["Contract_A_IdNumber"].ToString();
            model.Contract_A_Agent = dataReader["Contract_A_Agent"].ToString();
            if (dataReader["Contract_A_SureDate"].ToString() != "")
            {
                model.Contract_A_SureDate = DateTime.Parse(dataReader["Contract_A_SureDate"].ToString());
            }
            model.Contract_B_Name = dataReader["Contract_B_Name"].ToString();
            model.Contract_B_Address = dataReader["Contract_B_Address"].ToString();
            model.Contract_B_IdNumber = dataReader["Contract_B_IdNumber"].ToString();
            model.Contract_B_Agent = dataReader["Contract_B_Agent"].ToString();
            if (dataReader["Contract_B_SureDate"].ToString() != "")
            {
                model.Contract_B_SureDate = DateTime.Parse(dataReader["Contract_B_SureDate"].ToString());
            }
            if (dataReader["Contract_Date"].ToString() != "")
            {
                model.Contract_Date = DateTime.Parse(dataReader["Contract_Date"].ToString());
            }
            if (dataReader["Contract_Status"].ToString() != "")
            {
                model.Contract_Status = int.Parse(dataReader["Contract_Status"].ToString());
            }
            return model;
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Contract_Id,CityId,CityName,CompanyId,CompanyName,Contract_LastPrintUserId,Contract_LastPrintUserName,Contract_LastPrintDate,Contract_PrintCount,Contract_Type,Contract_Code,Contract_A,Contract_B,Contract_Content,Contract_PropertyCode,Contract_OwnerCode,Contract_LandUseCode,Contract_OtherCode,Contract_HouseArea,Contract_GargeArea,Contract_AtticCount,Contract_AtticArea,Contract_A_Identity,Contract_Use,Contract_OtherUse,Contract_RentStartDate,Contract_RentEndDate,Contract_ProvideDate,Contract_FreeDay,Contract_FreeStartDate,Contract_FreeEndDate,Contract_RenealDay,Contract_ReturnDay,Contract_LatePrice,Contract_EarnestDate,Contract_EarnestMoney,Contract_EarnestDay,Contract_EarnestUse,Contract_RentpriceDay,Contract_RentPriceMonth,Contract_RentPriceMonthUpper,Contract_RentPriceTax,Contract_PayMethod,Contract_PayUserName,Contract_PayUserCode,Contract_PayBank,Contract_A_Sure,Contract_RentKeep,Contract_RentKeepUnit,Contract_RentChange,Contract_RentChangeUnit,Contract_RentChangeContent,Contract_RentPayCycle,Contract_RentFirstDate,Contract_RentOtherTime,Contract_LateFree,Contract_LateOutDay,Contract_MarginCount,Contract_Margin,Contract_MarginUpper,Contract_OtherFreePay,Contract_MaintainDay,Contract_ApprovalUser,Contract_CanSublet,Contract_Liqui_Both,Contract_A_LateDay,Contract_B_LateDay,Contract_Liqui_Other,Contract_Liqui_A,Contract_ChangeDealType,Contract_ChangeDeal,Contract_Liqui,Contract_Liqui_B,Contract_Remark,Contract_Count,Contract_OwnerPersonalOther,Contract_A_Name,Contract_A_Address,Contract_A_IdNumber,Contract_A_Agent,Contract_A_SureDate,Contract_B_Name,Contract_B_Address,Contract_B_IdNumber,Contract_B_Agent,Contract_B_SureDate,Contract_Date,Contract_Status");
            strSql.Append(" FROM tb_ContractInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public static DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" Contract_Id,CityId,CityName,CompanyId,CompanyName,Contract_LastPrintUserId,Contract_LastPrintUserName,Contract_LastPrintDate,Contract_PrintCount,Contract_Type,Contract_Code,Contract_A,Contract_B,Contract_Content,Contract_PropertyCode,Contract_OwnerCode,Contract_LandUseCode,Contract_OtherCode,Contract_HouseArea,Contract_GargeArea,Contract_AtticCount,Contract_AtticArea,Contract_A_Identity,Contract_Use,Contract_OtherUse,Contract_RentStartDate,Contract_RentEndDate,Contract_ProvideDate,Contract_FreeDay,Contract_FreeStartDate,Contract_FreeEndDate,Contract_RenealDay,Contract_ReturnDay,Contract_LatePrice,Contract_EarnestDate,Contract_EarnestMoney,Contract_EarnestDay,Contract_EarnestUse,Contract_RentpriceDay,Contract_RentPriceMonth,Contract_RentPriceMonthUpper,Contract_RentPriceTax,Contract_PayMethod,Contract_PayUserName,Contract_PayUserCode,Contract_PayBank,Contract_A_Sure,Contract_RentKeep,Contract_RentKeepUnit,Contract_RentChange,Contract_RentChangeUnit,Contract_RentChangeContent,Contract_RentPayCycle,Contract_RentFirstDate,Contract_RentOtherTime,Contract_LateFree,Contract_LateOutDay,Contract_MarginCount,Contract_Margin,Contract_MarginUpper,Contract_OtherFreePay,Contract_MaintainDay,Contract_ApprovalUser,Contract_CanSublet,Contract_Liqui_Both,Contract_A_LateDay,Contract_B_LateDay,Contract_Liqui_Other,Contract_Liqui_A,Contract_ChangeDealType,Contract_ChangeDeal,Contract_Liqui_B,Contract_Liqui,Contract_Remark,Contract_Count,Contract_OwnerPersonalOther,Contract_A_Name,Contract_A_Address,Contract_A_IdNumber,Contract_A_Agent,Contract_A_SureDate,Contract_B_Name,Contract_B_Address,Contract_B_IdNumber,Contract_B_Agent,Contract_B_SureDate,Contract_Date,Contract_Status");
            strSql.Append(" FROM tb_ContractInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public static DataSet GetList(int PageIndex, int PageSize, String OrderField, string StrWhere, string FieldList, string TableFieldList, bool DoCount)
        {
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            DbCommand dbCommand = db.GetStoredProcCommand("PagerMultiTable");
            db.AddInParameter(dbCommand, "PageIndex", DbType.Int32, PageIndex);

            db.AddInParameter(dbCommand, "PageSize", DbType.Int32, PageSize);
            db.AddInParameter(dbCommand, "OrderField", DbType.AnsiString, OrderField);
            db.AddInParameter(dbCommand, "TableName", DbType.AnsiString, "tb_ContractInfo");
            db.AddInParameter(dbCommand, "StrWhere", DbType.AnsiString, StrWhere);
            db.AddInParameter(dbCommand, "FieldList", DbType.AnsiString, FieldList);
            db.AddInParameter(dbCommand, "TableFieldList", DbType.AnsiString, TableFieldList);
            db.AddInParameter(dbCommand, "DoCount", DbType.Boolean, DoCount);
            return db.ExecuteDataSet(dbCommand);
        }
        #endregion  成员方法
    }
}
